﻿package component.tree.dao;

import component.tree.util.ConfigUtil;

public class ConnectionProviderFactory {
	public static IConnectionProvider getConnectionProvider(){
		//IConnectionProvider connectionProvider = new ConnectionProvider();
		
		IConnectionProvider connectionProvider = null;
		
		String className = ConfigUtil.getConnectionProvider();
		if(className == null){
			connectionProvider = new ConnectionProvider();
		}else{
			Class c = null;
			try {
				c = Class.forName(className);
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			try {
				connectionProvider = (IConnectionProvider) c.newInstance();
			} catch (InstantiationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return connectionProvider;
	}
}
